home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d3
/
rettig.arc
/
TRSOURCE.EXE
/
_TR_HTOL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-22
|
739b
|
39 lines
/*********
*
* _TR_HTOL.C
*
* by Ralph Davis
*
* Placed in the public domain by Tom Rettig Associates, 10/22/1990.
*
* SYNTAX: _tr_htol(cp)
* char *cp;
*
* RETURN: long integer equivalent of cp
*
*********/
#include "trlib.h"
long _tr_htol(s) /* dec() internal function */
char *s;
{
int hexdigit, i;
long n;
n = 0L;
for (i = 0; i < _tr_strlen(s); i++)
{
if (s[i] >= '0' && s[i] <= '9')
hexdigit = s[i] - '0';
else if (s[i] >= 'a' && s[i] <= 'f')
hexdigit = s[i] - 'a' + 10;
else if (s[i] >= 'A' && s[i] <= 'F')
hexdigit = s[i] - 'A' + 10;
else
return(0L);
n = 16 * n + hexdigit;
}
return(n);
}